/**
 * Software License, Version 1.0
 * 
 * Copyright 2008 The Trustees of Indiana University.  All rights reserved.
 * 
 *
 *Redistribution and use in source and binary forms, with or without 
 *modification, are permitted provided that the following conditions are met:
 *
 *1) All redistributions of source code must retain the above copyright notice,
 * the list of authors in the original source code, this list of conditions and
 * the disclaimer listed in this license;
 *2) All redistributions in binary form must reproduce the above copyright 
 * notice, this list of conditions and the disclaimer listed in this license in
 * the documentation and/or other materials provided with the distribution;
 *3) Any documentation included with all redistributions must include the 
 * following acknowledgment:
 *
 *"This product includes software developed by the Community Grids Lab. For 
 * further information contact the Community Grids Lab at 
 * http://communitygrids.iu.edu/."
 *
 * Alternatively, this acknowledgment may appear in the software itself, and 
 * wherever such third-party acknowledgments normally appear.
 * 
 *4) The name Indiana University or Community Grids Lab or Granules, 
 * shall not be used to endorse or promote products derived from this software 
 * without prior written permission from Indiana University.  For written 
 * permission, please contact the Advanced Research and Technology Institute 
 * ("ARTI") at 351 West 10th Street, Indianapolis, Indiana 46202.
 *5) Products derived from this software may not be called Granules, 
 * nor may Indiana University or Community Grids Lab or Granules appear
 * in their name, without prior written permission of ARTI.
 * 
 *
 * Indiana University provides no reassurances that the source code provided 
 * does not infringe the patent or any other intellectual property rights of 
 * any other entity.  Indiana University disclaims any liability to any 
 * recipient for claims brought by any other entity based on infringement of 
 * intellectual property rights or otherwise.  
 *
 * LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH NO 
 * WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA UNIVERSITY GIVES
 * NO WARRANTIES AND MAKES NO REPRESENTATION THAT SOFTWARE IS FREE OF 
 * INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR OTHER PROPRIETARY RIGHTS. 
 * INDIANA UNIVERSITY MAKES NO WARRANTIES THAT SOFTWARE IS FREE FROM "BUGS", 
 * "VIRUSES", "TROJAN HORSES", "TRAP DOORS", "WORMS", OR OTHER HARMFUL CODE.  
 * LICENSEE ASSUMES THE ENTIRE RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR 
 * ASSOCIATED MATERIALS, AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION 
 * GENERATED USING SOFTWARE.
 */
package cgl.granules.operation;

import cgl.granules.scheduler.TaskLifecycleMetrics;

/**
 * <code>JobLifecycleObserver</code> is the interface which needs to be
 * implemented by an entity which wishes to observe the execution of a Job and
 * its constituent tasks. As the job progresses in it's execution phase, the
 * observer is used to report on the highlights -- such as the start and end of
 * a task -- of the job's execution.
 * 
 * @author Shrideep Pallickara
 * 
 */
public interface JobLifecycleObserver {

	/**
	 * This method is invoked when all the constituent distributed tasks have
	 * finished executing successfully.
	 * 
	 * @param jobIdentifier
	 *            The ID of the Job being reported on
	 * @param progressTracker
	 *            Contains information about the lifecycle metrics associated
	 *            with the constituent tasks.
	 */
	public void completedSuccessfully(String jobIdentifier,
			ProgressTracker progressTracker);

	/**
	 * This method is invoked when we have heard from all the sub-tasks, and one
	 * or more errors have been encountered in the execution of constituent
	 * tasks.
	 * 
	 * @param jobIdentifier
	 *            The ID of the Job being reported on
	 * @param progressTracker
	 *            Contains information about the lifecycle metrics associated
	 *            with the constituent tasks.
	 */
	public void completedWithErrors(String jobIdentifier,
			ProgressTracker progressTracker);

	/**
	 * This method is invoked when the <i>first</i> task reports that it has
	 * begun execution.
	 * 
	 * @param jobIdentifier
	 *            The ID of the Job being reported on
	 * @param taskIdentifier
	 *            The taskId of one of the constituent tasks that has started
	 *            execution.
	 */
	public void startedExecution(String jobIdentifier, String taskIdentifier);

	/**
	 * This method is invoked when a task has completed execution either
	 * successfully or due to an abnormal termination or previously issued abort
	 * request. Invoking the
	 * <code>taskLifecycleMetrics.getExecutionStatus()</code> method and
	 * comparing it to the constants in the metrics, reveals the completion
	 * status of the task.
	 * 
	 * @param jobIdentifier
	 *            The ID of the Job being reported on
	 * @param taskIdentifier
	 *            The taskId of one of the constituent tasks
	 * @param taskLifecycleMetrics
	 *            The metrics associated with the task in question.
	 */
	public void completedExecution(String jobIdentifier, String taskIdentifier,
			TaskLifecycleMetrics taskLifecycleMetrics);

}
